package com.alpha.feign.common;

import com.alpha.core.http.Response;
import com.alpha.feign.common.entity.Tenant;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 租户接口
 *
 * @author chenruwan
 * @since 2022-01-01
 */
@FeignClient(value = "alpha-common", contextId = "tenants")
public interface TenantFeignClient {
    /**
     * 获取租户详情
     *
     * @param id 租户Id
     * @return 租户信息
     */
    @GetMapping("/tenants/{id}")
    Response<Tenant> get(@PathVariable("id") Long id);

    /**
     * 新增租户
     *
     * @param tenant 租户信息
     * @return 租户Id
     */
    @PostMapping("/tenants")
    Response<Long> save(@Validated @RequestBody Tenant tenant);

    /**
     * 更新租户信息
     *
     * @param id     租户Id
     * @param tenant 租户信息
     * @return Response
     */
    @PutMapping("/tenants/{id}")
    Response<Object> update(@PathVariable("id") Long id, @Validated @RequestBody Tenant tenant);

    /**
     * 删除租户
     *
     * @param id 租户Id
     * @return Response
     */
    @DeleteMapping("/tenants/{id}")
    Response<Object> delete(@PathVariable("id") Long id);
}
